<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class WizardApp extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model("wizard_model", "w_model");
    }

    public function preview($idWizard)
    {
        $data['wizard'] = $this->w_model->getPreview($idWizard);
        $idQuestion = "";
        $i = 0;
        $data['questions'] = array();
        foreach($data['wizard']['questions'] as $question){
            if($question->idQuestion != $idQuestion){
                $idQuestion = $question->idQuestion;
                $data['questions'][$i++] = array(
                    'strQuestion' => $question->strQuestion,
                    'idQuestion' => $question->idQuestion,
                    'question_type' => $question->question_type,
                    'id_question_type' => $question->id_question_type
                );
            }
            $data['questions'][$i - 1]['answers'][] = array(
                'strAnswer' => $question->strAnswer,
                'idAnswer' => $question->idAnswer,
                'intPoints' => $question->intPoints
            );
        }
        $data['wizard']['questions'] = NULL;
        echo $this->load->view('wizard_preview_view', $data, true);
    }

    public function new_tab(){
        $data['page'] = array('root' => '../../', 'active' => 'tab');
        $this->load->view('home_header', $data['page']);
        $data['html'] = $this->generateType('tab');
        #Formulario de creación para el tab
        $this->load->view('new_wizard', $data['html']);
        $this->load->view('home_footer', $data['page']);
    }

    public function generateType($type){
        switch($type){
            case 'tab':{

            }
        }
    }
    public function algo(){
        echo 'yeeei';
    }
}